package com.bigshen.springcloud.clients;

import com.bigshen.springcloud.api.R;
import com.bigshen.springcloud.dto.ItemStockDto;
import com.bigshen.springcloud.vo.ItemDetailVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@FeignClient(value = "shen-mall-goods-service")
public interface IGoodsFeignClient {

    /**
     * 锁定并扣减库存
     * @param itemStockDtoList  商品id、库存数量
     * @return
     */
    @PutMapping(value = "/items/stock", consumes = MediaType.APPLICATION_JSON_VALUE)
    R decreaseStock(@RequestBody List<ItemStockDto> itemStockDtoList);

    /**
     * 根据商品id查询商品列表
     * @param ids
     * @return
     */
    @GetMapping(value = "/items/{ids}")
    R<List<ItemDetailVo>> getItemsByIds(@PathVariable("ids") List<Long> ids);

}
